home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / NOTETAB.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  6KB  |  238 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.9  $
  6. //
  7. // Definition of class TNoteTab
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_NOTETAB_H)
  10. #define OWL_NOTETAB_H
  11.  
  12. // Macro defining class name (usable in resource definition)
  13. //
  14. #if !defined(OWL_NOTETAB)
  15. # define OWL_NOTETAB "OWL_Notetab"
  16. #endif
  17.  
  18. #if !defined(RC_INVOKED)
  19.  
  20. #if !defined(OWL_CONTROL_H)
  21. # include <owl/control.h>
  22. #endif
  23. #if !defined(CLASSLIB_VECTIMP_H)
  24. # include <classlib/vectimp.h>
  25. #endif
  26. #if !defined(OWL_COMMCTRL_H)
  27. # include <owl/commctrl.h>
  28. #endif
  29.  
  30. #if defined(BI_NAMESPACE)
  31. namespace OWL {
  32. #endif
  33.  
  34. // Generic definitions/compiler options (eg. alignment) preceeding the 
  35. // definition of classes
  36. #include <services/preclass.h>
  37.  
  38. class _OWLCLASS TFont;
  39.  
  40. //
  41. // class TNoteTabItem
  42. // ~~~~~ ~~~~~~~~~~~~
  43. // TNoteTabItem holds information about each tab in a notetab control.
  44. // For example, the structure contains information about the title and size
  45. // of each tab item.
  46. //
  47. struct TNoteTabItem
  48. {
  49.     TNoteTabItem(const char* label, uint32 clientData = 0);
  50.     TNoteTabItem();
  51.  
  52.     TRect     Rect;             // Location of tab [client-area base coords]
  53.     string    Label;            // Label of tab
  54.     TSize     LabelSize;        // Width and height of label
  55.     uint32    ClientData;       // User-defined data associated with item
  56. };
  57.  
  58. //
  59. // class TNoteTab
  60. // ~~~~~ ~~~~~~~~
  61. // TNoteTab encapsulates a tab control with each tab item along the bottom
  62. // of the window.
  63. //
  64. class _OWLCLASS TNoteTab : public TControl {
  65.   public:
  66.     TNoteTab(TWindow*   parent,
  67.              int        id,
  68.              int x, int y, int w, int h,
  69.              TWindow*   buddy = 0,
  70.              bool       dialogBuddy = true,
  71.              TModule*   module = 0);
  72.  
  73.     TNoteTab(TWindow* parent, int resourceId,
  74.              TWindow* buddy = 0, 
  75.              bool     dialogBuddy = true,
  76.              TModule* module = 0);
  77.    ~TNoteTab();
  78.  
  79.     // Add/remove tab items
  80.     //
  81.     int         Add(const char* txt, uint32 clientData = 0);
  82.     int         Insert(const char* txt, int index, uint32 clientData = 0);
  83.     bool        Delete(int index);
  84.     bool        DeleteAll();
  85.  
  86.     // Set/Query attributes of TabControl
  87.     //
  88.     int         GetCount() const;
  89.     int         GetSel() const;
  90.     int         SetSel(int index);
  91.     void        SetWindowFace(bool);         
  92.     bool        GetWindowFace() const;         
  93.     void        SetStyle3d(bool);            
  94.     bool        GetStyle3d() const;
  95.  
  96.     // Set/Query attributes of Tab Items
  97.     //
  98.     bool        GetItem(int index, TNoteTabItem& item) const;
  99.     bool        SetItem(int index, const TNoteTabItem& item);
  100.     bool        IsVisible(int index) const;
  101.  
  102.     // Set/Query buddy window
  103.     //
  104.     HWND        GetBuddy() const;
  105.     void        SetBuddy(HWND buddy);
  106.  
  107.     // Override TWindow virtual member function to handle transfers
  108.     //
  109.     uint        Transfer(void* buffer, TTransferDirection direction);
  110.  
  111.   protected:
  112.  
  113.     // Override TWindow virtual member functions
  114.     //
  115.     char far*   GetClassName();
  116.     void        SetupWindow();
  117.     void        Paint(TDC& dc, bool erase, TRect& rect);
  118.  
  119.     // Message Handlers
  120.     //
  121.     void        EvSize(uint sizeType, TSize& size);
  122.     void        EvLButtonDown(uint modKeys, TPoint& point);
  123.     uint        EvGetDlgCode(MSG far* msg);
  124.     void        EvKeyDown(uint key, uint repeatCount, uint flags);
  125.     void        EvSetFocus(THandle hWndLostFocus);
  126.     void        EvKillFocus(THandle hwndGetFocus);
  127.  
  128.  
  129.     // Routines handling underlying implementation
  130.     //
  131.     void        InitCtrl();
  132.     void        SetupFont(HFONT font = 0);
  133.     void        SetTabRects(int firstTab);
  134.     void        InvalidateTabRect(int index);
  135.     void        SetTabSize(int index);
  136.     int         TabFromPoint(const TPoint& pt);
  137.     void        GetTabsArea(TRect& rect);
  138.     void        GetScrollerArea(TRect& rect);
  139.     void        NotifyAndSelect(int index);
  140.  
  141.   protected_data:
  142.     bool        WindowFace;         // Active tab should use window color
  143.     bool        Style3d;            // Draw with 3d style
  144.     int         TopMargin;          // amount of space to res
  145.  
  146.   private:
  147.     // Hidden to prevent accidental copying or assignment
  148.     //
  149.     TNoteTab(const TNoteTab&);
  150.     TNoteTab& operator =(const TNoteTab&);
  151.  
  152.     TFont*      TabFont;
  153.     TWindow*    Buddy;
  154.     THandle     BuddyHandle;
  155.     TRect       ScrollRect;
  156.     int         FirstVisibleTab;
  157.     int         SelectedTab;
  158.     TCVectorImp<TNoteTabItem*>* TabList;
  159.  
  160.     void        DrawFocusRect(TDC& dc);
  161.     
  162.   DECLARE_RESPONSE_TABLE(TNoteTab);
  163. };
  164.  
  165. // Generic definitions/compiler options (eg. alignment) following the 
  166. // definition of classes
  167. #include <services/posclass.h>
  168.  
  169. #if defined(BI_NAMESPACE)
  170. } // namespace OWL
  171. #endif
  172.  
  173. //----------------------------------------------------------------------------
  174. // Inline implementations
  175.  
  176. //
  177. // Constructor of Notetab Item object. Initializes object with specified
  178. // string label and optional user-defined data.
  179. //
  180. inline
  181. TNoteTabItem::TNoteTabItem(const char* label, uint32 clientData)
  182.   Label(label),
  183.   ClientData(clientData)
  184. {
  185. }
  186.  
  187. //
  188. // Default constructor of Notetab Item object.
  189. //
  190. inline
  191. TNoteTabItem::TNoteTabItem()
  192. {
  193. }
  194.  
  195. //
  196. // Specify whether active tab should use the system's window color. If the
  197. // the 'wf' parameter is true, the system's window color is used.
  198. //
  199. inline void 
  200. TNoteTab::SetWindowFace(bool wf)
  201. {
  202.   WindowFace = wf;
  203. }
  204.  
  205. //
  206. // Return the flag specifying whether the active tab should use the system's
  207. // window color.
  208. //
  209. inline bool 
  210. TNoteTab::GetWindowFace() const
  211. {
  212.   return WindowFace;
  213. }
  214.  
  215. //
  216. // Specify whether the note tab should draw a 3D edge. if 'st' is true, the
  217. // control displays a 3D edge.
  218. //
  219. inline void 
  220. TNoteTab::SetStyle3d(bool st)
  221. {
  222.   Style3d = st;
  223. }
  224.  
  225. //
  226. // Return the flag specifying whether the notetab control should draw a 3D
  227. // border.
  228. //
  229. inline bool 
  230. TNoteTab::GetStyle3d() const
  231. {
  232.   return Style3d;
  233. }
  234.  
  235. #endif  // !RC_INVOKED 
  236. #endif  //  OWL_NOTETAB_H
  237.